<template>
	<view id="tmpl">
		<view class="resource">
			<image v-show="image1" :src="image1" />
			<image v-show="image2" :src="image2" />
			<image v-show="image3" :src="image3" />
			<video v-show="videoPath" :src="videoPath"></video>
		</view>
		<view class="content-container" v-html="content"></view>
		<view class="line-button" @click="GoToPage('peixun','post-form?id='+id +'&title='+title)">
			<text>上传心得</text>
		</view>
	</view>
</template>

<script>
	import config from '../../static/common/config.js'

	export default {
		data() {
			return {
				id: 0,
				title: '',
				content: '',
				image1: '',
				image2: '',
				image3: '',
				videoPath: ''
			}
		},
		methods: {
			onLoad: function(options) {
				let _this = this;
				this.id = options.id
				this.title = options.title
				uni.setNavigationBarTitle({
					title: options.title
				})
				this.$api.get_px(this.id).then(res => {
					console.log(res)
					_this.content = res.data.data.content;
					_this.image1 = res.data.data.image1Path ? config + res.data.data.image1Path : ''
					_this.image2 = res.data.data.image2Path ? config + res.data.data.image2Path : ''
					_this.image3 = res.data.data.image3Path ? config + res.data.data.image3Path : '';
					_this.videoPath = res.data.data.videoPath ? config + res.data.data.videoPath : '';
				})
				console.log(_this.image1)
				console.log(_this.image2)
				console.log(_this.image3)
				console.log(_this.content)
			},
			onShow: function() {
				this.$_if.Initialize(this);
				let is_login = uni.getStorageSync('user_token') ? true : false;
				if (!is_login) {
					uni.navigateTo({
						url: '../profile/user_login'
					})
				}
			},
		}
	}
</script>

<style lang="scss" >
	page {
		margin-bottom: 80upx;
		background-color: #fff;
	}

	.line-button {
		@extend .line-button;

		text {
			width: 100%;
			border-radius: 0;
			position: fixed;
			bottom: 0;
		}
	}

	.resource {
		text-align: center;
	}
	
	.content-container{
		padding: 20upx;
	}
</style>
